import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { ChristmasActivitiesInfo } from "../model/ChristmasActivitiesInfo";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class ChristmasActivitiesConfig
    
    export  class ChristmasActivitiesConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._list = [];
            this._recallOldPlayerActivitiesList = [];
            if (ChristmasActivitiesConfig._instance != null) 
            {
                throw new Error(" ChristmasActivitiesConfig 单例 ");
            }
            this.init();
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_christmasactivities.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            this._list.splice(0);
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new ChristmasActivitiesInfo();
                loc1.code = loc2.code;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.imgSrc = StringHelper.getString(loc2.imgsrc);
                loc1.mapId = loc2.mapid;
                loc1.targetId = loc2.targetid;
                loc1.px = loc2.px;
                loc1.py = loc2.py;
                loc1.type = loc2.type;
                loc1.condition = loc2.condition;
                loc1.des = StringHelper.getString(loc2.des);
                loc1.rewards = StringHelper.getString(loc2.reward);
                loc1.items = StringHelper.getString(loc2.items);
                loc1.startStr = StringHelper.getString(loc2.start);
                loc1.endStr = StringHelper.getString(loc2.end);
                loc1.maxLevel = loc2.maxLevel;
                loc1.minLevel = loc2.minLevel;
                if (loc2.hasOwnProperty("notShowInNewServer")) 
                {
                    loc1.notShowInNewServer = loc2.notShowInNewServer;
                }
                loc1.updateData();
                this._map[loc1.code] = loc1;
                if (loc1.code < 1000) 
                {
                    this._list.push(loc1);
                    continue;
                }
                this._recallOldPlayerActivitiesList.push(loc1);
            }
            this._list.sortOn("code", Array.NUMERIC);
            this._recallOldPlayerActivitiesList.sortOn("code", Array.NUMERIC);
            return;
        }

        public getInfoByType(arg1: int): ChristmasActivitiesInfo
        {
            return this._map[arg1] as ChristmasActivitiesInfo;
        }

        public getActiveList(): Array<any>
        {
            return this._list;
        }

        public ChristmasActivitiesConfig.get recallOldPlayerActivitiesList(): Array<any>
        {
            return this._recallOldPlayerActivitiesList;
        }

        public static get instance(): ChristmasActivitiesConfig
        {
            if (ChristmasActivitiesConfig._instance == null) 
            {
                ChristmasActivitiesConfig._instance = new ChristmasActivitiesConfig();
            }
            return ChristmasActivitiesConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_list: Array<any>;

        /* internal */ /* var */_recallOldPlayerActivitiesList: Array<any>;

        /* internal */ static /* var */_instance: ChristmasActivitiesConfig;
    }
